﻿using System.Collections.Generic;
using System.Linq;
using Rhino.Etl.Core.Operations;

namespace Sqloogle.Operations.Support {

    public static class UnionFactory {

        public static AbstractOperation Build(params IOperation[] ops) {

            if (ops.Length == 1)
                return new UnionAllOperationSerial(ops);
#if DEBUG
            return new UnionAllOperationSerial(ops);
#else
            return new UnionAllOperationParallel2(ops);
#endif
        }

        public static AbstractOperation Build(IEnumerable<IOperation> ops) {
            var opsArray = ops.ToArray();
            if (opsArray.Count() == 1)
                return new UnionAllOperationSerial(opsArray);
#if DEBUG
            return new UnionAllOperationSerial(opsArray);
#else
            return new UnionAllOperationParallel2(opsArray);
#endif
        }
    }
}
